<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="../../../adminthemes/version3/js/jquery-1.9.1.min.js"></script>
    <link rel="stylesheet" href="/adminthemes/bootstrop/bootstrap/dist/css/bootstrap.css">
    <script src="../../../adminthemes/bootstrop/bootstrap/dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="../../../adminthemes/layuii/layui/css/layui.css">
    <script src="../../../adminthemes/layuii/layui/layui.js"></script>
    <link rel="stylesheet" href="../../../adminthemes/version3/plugins/layui/css/layui.css">
    <script src="../../../adminthemes/version3/plugins/layui/layui.js"></script>
</head>
<body>
<h6 align="center">添加保险</h6>
    <div style="padding: 30px 30px 10px;">
        <form class="bs-example bs-example-form" role="form" action="/web/InsuranceManage/addGoods.do" method="post" id="insuranceForm">
            <input type="hidden" name="type_id" id="type_id"/>
            <input type="hidden" name="havaSpec" id="haveSpec" value="1"/>
            <input type="hidden" name="city_area_code"/>
            <input type="hidden" name="region_area_code"/>

            <div style="text-align: center">
            <div class="input-group input-group-lg" style="margin: 20px">
                <span class="input-group-addon">保险分类</span>
                <select id="cat_id" name="cat_id" class="combobox form-control col-lg-3"  style="width: 25%;height: 50px">
                    <#list catList as cat>
                    <if cat??>
                        <option value="${cat.cat_id}">${cat.name}</option>
                    </if>
                </#list>
                </select>
                <select id="cat_id1" name="cat_id1" class="combobox form-control col-lg-3" style="width: 25%;height: 50px">
                </select>
                <select id="cat_id2" name="cat_id2" class="combobox form-control col-lg-3" style="width: 25%;height: 50px">
                </select>
            </div>
            <div class="input-group input-group-lg" style="margin: 20px">
                <span class="input-group-addon">保险名称</span>
                <input type="text" id="name" name="name" class="form-control col-lg-3" placeholder="保险名称" style="width: 40%;height: 50px">
            </div>
            <div class="input-group input-group-lg" style="margin: 20px">
                <span class="input-group-addon">保险编号</span>
                <input type="text" id="sn" name="sn" class="form-control col-lg-3" placeholder="保险编号" style="width: 40%;height: 50px">
            </div>
            <div class="input-group input-group-lg" style="margin: 20px">
                <span class="input-group-addon">供应商</span>
                <select id="supplier_id" name="supplier_id" class="combobox form-control col-lg-3"  style="width: 40%;height: 50px">
                    <#list supplierList as supplier>
                    <if supplier??>
                        <option value="${supplier.id}">${supplier.supplier_name}</option>
                    </if>
                </#list>
                </select>
            </div>
            <div class="input-group input-group-lg" style="margin: 20px" id="">
                <table class="form-table spec-form-table">
                    <tbody>
                    <tr>
                        <th>保障期限：</th>
                        <td>
                            <ul class="spec" specname="保障期限">
                                <li style="margin: 5px;">
                            <span>
                                <input class="chk" autocomplete="off" lay-ignore type="checkbox" value="86" spec_value="3个月" specid="10" specmemo=""/>
                            </span>
                                    <span>
                                <input style="border:none;" type="text" class="change-spec-value" value="3个月" readonly>
                            </span>
                                </li>
                                <li style="margin: 5px;">
                            <span>
                                <input class="chk" autocomplete="off" lay-ignore type="checkbox" value="87" spec_value="6个月" specid="10" specmemo=""/>
                            </span>
                                    <span>
                                <input style="border:none;" type="text" class="change-spec-value" value="6个月" readonly>
                            </span>
                                </li>
                                <li style="margin: 5px;">
                            <span>
                                <input class="chk" autocomplete="off" lay-ignore type="checkbox" value="88" spec_value="9个月" specid="10" specmemo=""/>
                            </span>
                                    <span>
                                <input style="border:none;" type="text" class="change-spec-value" value="9个月" readonly>
                            </span>
                                </li>
                                <li style="margin: 5px;">
                            <span>
                                <input class="chk" autocomplete="off" lay-ignore type="checkbox" value="89" spec_value="一年" specid="10" specmemo=""/>
                            </span>
                                    <span>
                                <input style="border:none;" type="text" class="change-spec-value" value="一年" readonly>
                            </span>
                                </li>
                            </ul>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="detail" >
                <table class="spec_table layui-table"  cellspacing="0" cellpadding="0" border="0" >
                    <thead></thead>
                </table>
            </div>
            <div class="input-group input-group-lg" style="margin: 20px">
                <span class="input-group-addon">保险详情</span>
                <input id="intor" name="intor" type="text" class="form-control col-lg-3" style="width: 40%;height: 50px" />
            </div>
            <div class="input-group input-group-lg" style="margin: 20px">
                <span class="input-group-addon">是否上架</span>
                <select type="text" id="market_enable" name="market_enable" class="form-control col-lg-3" placeholder="" style="width: 40%;height: 50px">
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
            </div>
            <div class="input-group input-group-lg" style="margin: 20px">
                <span class="input-group-addon">保险价格</span>
                <input type="text" id="price" name="price" class="form-control col-lg-3" placeholder="保险价格" style="width: 40%;height: 50px">
            </div>
            <div class="input-group input-group-lg" style="margin: 20px">
                <span class="input-group-addon">积分</span>
                <input type="text" id="point" name="point" class="form-control col-lg-3" placeholder="积分" style="width: 40%;height: 50px">
            </div>
            </div>
            <div title="区域信息" style="margin: 20px" >
                <div class="input-group input-group-lg">
                    <span class="input-group-addon">保险投放区域</span>
                    <select id="province_area_code" name="province_area_code" class="combobox form-control col-lg-3" style="width: 25%;height: 50px">
                        <#list sysAreaList as area>
                        <if area??>
                            <option value="${area.area_code}">${area.area_name}</option>
                        </if>
                    </#list>
                    </select>
                    <select id="city_area_code" name="city_area_code" class="combobox form-control col-lg-3" style="width: 25%;height: 50px">
                    </select>
                    <select id="region_area_code" name="area_code" class="combobox form-control col-lg-3" style="width: 25%;height: 50px">
                    </select>
                </div>
            </div>
            <div title="保险方案" style="padding: 30px 30px 10px;">
                <input type="hidden" name="groupnames" value="保险方案" />
                <input type="hidden" name="paramnums" value="9" />
                <div class="input-group input-group-lg" style="margin: 20px">
                    <span class="input-group-addon" name="paramnames" value="保险标的">保险标的</span>
                    <input type="text" id="item" name="item" class="form-control col-lg-3"  style="width: 40%;height: 50px">
                </div>
                <!--<div class="input-group input-group-lg" style="margin: 20px">-->
                    <!--<span class="input-group-addon">每次事故免赔率(%)</span>-->
                    <!--<input type="text" id="avoid_subsidies" name="avoid_subsidies" class="form-control col-lg-3"  style="width: 40%;height: 50px">-->
                <!--</div>-->
                <div class="input-group input-group-lg" style="margin: 20px">
                    <span class="input-group-addon" name="paramnames" value="保险费率(%)">保险费率(%)</span>
                    <input type="text" id="insured_subsidies" name="paramvalues" class="form-control col-lg-3"  style="width: 40%;height: 50px">
                </div>
                <div class="input-group input-group-lg" style="margin: 20px">
                    <span class="input-group-addon" name="paramnames" value="中央财政补贴比例(%)">中央财政补贴比例(%)</span>
                    <input type="text" id="central_subsidies" name="paramvalues" class="form-control col-lg-3"  style="width: 40%;height: 50px" value="40">
                </div>
                <div class="input-group input-group-lg" style="margin: 20px">
                    <span class="input-group-addon" name="paramnames" value="省财政补贴比例(%)">省财政补贴比例(%)</span>
                    <input type="text" id="province_subsidies" name="paramvalues" class="form-control col-lg-3"  style="width: 40%;height: 50px" value="35">
                </div>
                <div class="input-group input-group-lg" style="margin: 20px">
                    <span class="input-group-addon" name="paramnames" value="地方财政补贴比例(%)">地方财政补贴比例(%)"</span>
                    <input type="text" id="city_subsidies" name="paramvalues" class="form-control col-lg-3"  style="width: 40%;height: 50px" value="4">
                </div>
                <div class="input-group input-group-lg" style="margin: 20px">
                    <span class="input-group-addon" name="paramnames" value="县区补贴比例(%)">县区补贴比例(%)</span>
                    <input type="text" id="region_subsidies" name="paramvalues" class="form-control col-lg-3"  style="width: 40%;height: 50px" value="9.333333">
                </div>
                <div class="input-group input-group-lg" style="margin: 20px">
                    <span class="input-group-addon" name="paramnames" value="农户费率比例(%)">农户费率比例(%)</span>
                    <input type="text" id="farmer_subsidies" name="paramvalues" class="form-control col-lg-3"  style="width: 40%;height: 50px" value="11.666667">
                </div>
                <div class="input-group input-group-lg" style="margin: 20px">
                    <span class="input-group-addon" name="paramnames" value="其他费率比例(%)">其他费率比例(%)</span>
                    <input type="text" id="other_subsidies" name="paramvalues" class="form-control col-lg-3"  style="width: 40%;height: 50px" value="0">
                </div>
                <div class="input-group input-group-lg" style="margin: 20px">
                    <span class="input-group-addon" name="paramnames" value="险种说明"></span>
                    <textarea type="text" name="paramvalues" class="form-control col-lg-3" placeholder="保险说明" style="width: 40%;height: 100px"></textarea>
                </div>
            </div>
        </div>
        <div id="fat-btn">
            <button type="button" class="layui-btn" id="save" lay-submit="" onclick="checkForm()">立即提交</button>
        </div>
        </form>
    </div>
</body>
</html>
<script type="text/javascript">
     function checkForm(){
        var city_area_code = $("select[name='city_area_code']").val();
        var region_area_code = $("select[name='region_area_code']").val();
        if(city_area_code!=null){
            $("input[name='city_area_code']").val(city_area_code);
        }
        if(city_area_code!=null){
            $("input[name='region_area_code']").val(region_area_code);
        }
        $("#insuranceForm").submit();
     }
     // form.on('submit(goodsinput)', function(data) {
     //     var cat_id=$("select[name='cat_id']").val()
     //     if(cat_id==231){
     //         $("#type_id").val(69)
     //     }
     //     if(cat_id==244){
     //         $("#type_id").val(70)
     //     }
         //如果商品开启了规格，就必须添加规格，否则无法保存	add by DMRain 2016-2-191
         // if($("#haveSpec").val() == 1){
         //     if($("#spec-input .detail .spec_table tbody tr").length == 0){
         //         $.Loading.error("您已开启规格，但是还未添加规格，请添加后再保存！");
         //         return false;
         //     }
         // }
         //图片上传判定
         // if(typeof($("input[name='picnames']").val()) == "undefined"){
         //     $.Loading.error("图片必须上传！");
         //     return false;
         // }
         // 判定设置库存是否大于实际库存
         // if(parseInt($(".stock").val()) > parseInt($(".stock").attr("rel"))){
         //     $.Loading.error("对不起，库存不足！");
         //     return false;
         // }

     //     var options = {
     //         url : "/web/InsuranceManage/addGoods.do",
     //         type : "POST",
     //         dataType : "json",
     //         beforeSend:function(){ //触发ajax请求开始时执行
     //             /* $('#save').attr('onclick','javascript:void();');//改变提交按钮上的文字并将按钮设置为不可点击
     //             }, */
     //             $('#save').attr("disabled", true);
     //         },
     //         success : function(result) {
     //             if (result.result == 1) {
     //                 $.Loading.success(result.message);
     //                 closeCurrent();
     //             }else{
     //                 $.Loading.error(result.message);
     //                 $("#goodsinput").linkbutton("enable");
     //             }
     //         },
     //         error : function(e) {
     //             $.Loading.success("出错了,请重试");
     //             $("#goodsinput").linkbutton("enable");
     //         }
     //     };
     //
     //     $('#insuranceForm').ajaxSubmit(options);
     //
     //     return false;
     // });


     // layui.use('upload', function(){
     //     var $ = layui.jquery
     //         ,upload = layui.upload;
     //     //普通图片上传
     //     var uploadInst = upload.render({
     //         elem: '#test1'
     //         ,url: '/web/InsuranceManage/upload/inpolicyImage.do'
     //         ,before: function(obj){
     //             //预读本地文件示例，不支持ie8
     //             obj.preview(function(index, file, result){
     //                 $('#pic1').attr('src', result); //图片链接（base64）
     //             });
     //         }
     //         ,done: function(res){
     //             if(res.success){
     //                 $("#pic1").val(res.result);
     //                 return   layer.alert('上传成功！');
     //             }
     //         }
     //     })
     // });

     $("#province_area_code").change(function () {
         var id=$("#province_area_code").val();
         var postData={id:id,};
         $.ajax({
             type: "Get",
             url: "/web/sysarea/getSysCityByProvinceId.do",
             data: postData,
             dataType: "json",
             success: function (data) {
                 if(data.status){
                     var result = "<option>选择城市</option>";
                     $.each(data.obj,function(n,value){
                         result +="<option value='"+value.area_code+"'>"+value.area_name+"</option>";
                     });
                     $("#city_area_code").html('');
                     $("#city_area_code").append(result);
                 }
             }
         })
     });

     $("#city_area_code").change(function () {
         var id=$("#city_area_code").val();
         var postData={id:id,};
         $.ajax({
             type: "Get",
             url: "/web/sysarea/getSysAreaByCityId.do",
             data: postData,
             dataType: "json",
             success: function (data) {
                 if(data.status){
                     var result = "<option>选择城市</option>";
                     $.each(data.obj,function(n,value){
                         result +="<option value='"+value.area_code+"'>"+value.area_name+"</option>";
                     });
                     $("#region_area_code").html('');
                     $("#region_area_code").append(result);
                 }
             }
         })
     });


     $("#cat_id").change(function () {
         var id=$("#cat_id").val();
         var postData={id:id,};
         $.ajax({
             type: "Get",
             url: "/web/inpolicyCat/getTwoCat.do",
             data: postData,
             dataType: "json",
             success: function (data) {
                 if(data.status){
                     var result = "<option>请选择</option>";
                     $.each(data.obj,function(n,value){
                         result +="<option value='"+value.cat_id+"'>"+value.name+"</option>";
                     });
                     $("#cat_id1").html('');
                     $("#cat_id1").append(result);
                 }
             }
         })
     });

     $("#cat_id1").change(function () {
         var id = $("#cat_id1").val();
         var postData = {id: id,};
         $.ajax({
             type: "Get",
             url: "/web/inpolicyCat/getTwoCat.do",
             data: postData,
             dataType: "json",
             success: function (data) {
                 if (data.status) {
                     var result = "<option>请选择</option>";
                     $.each(data.obj, function (n, value) {
                         result += "<option value='" + value.cat_id + "'>" + value.name + "</option>";
                     });
                     $("#cat_id2").html('');
                     $("#cat_id2").append(result);
                 }
             }
         })
     })

     // Product.createEmptyTable();
     // Product.doCreatePros()

</script>